<?php

namespace App\Models;

use App\Helpers\Api\MyCacheTrait;

class Animal extends Base
{
    use MyCacheTrait;
    const DOG = 1;
    const CAT = 178;
    const SMALL = 227;
    const WATER= 497;
    CONST CREEP = 751;

    protected $appends = ['birthday_txt'];

    protected $fillable = ['id', 'user_id', 'title', 'gender', 'sort', 'parent_category_id', 'category_id', 'category_title', 'birthday', 'birthday_md','adopt_date',
        'sterilization', 'desc', 'logo', 'width', 'height', 'id_card', 'share_num', 'share_reg_num', 'created_at', 'updated_at'];

    public function category() {
        return $this->belongsTo(Category::class, 'category_id');
    }

    public function getBirthdayTxtAttribute() {
        return diffDate($this->birthday);
    }

    public function user() {
        return $this->belongsTo(User::class, 'user_id');
    }
}
